<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <title></title>
    <meta name="renderer" content="webkit" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="viewport"
        content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0" />
    <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all" />
    <style>
        .layui-form-item .layui-input-inline {
            width: 150px;
        }

        .layui-form-label {
            padding: 9px 5px;
            width: auto;
        }
    </style>
</head>

<body>
    <div class="layui-fluid">
        <div class="layui-card">
            <div class="layui-card-body">
                <div class="layui-form" lay-filter="">
                    <div class="layui-form-item">
                        <div class="layui-block">
                            <label class="layui-form-label">输入跳转链接</label>
                            <div class="layui-input-block">
                                <input type="text" name="link" value="http://" class="layui-input" lay-verify="" />
                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-block">
                            <label class="layui-form-label">生成一次性地址</label>
                            <div class="layui-input-block">
                                <input type="text" name="gen" id="gen" readonly value="" class="layui-input .gen"
                                    lay-verify="" />
                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-input-block text-center">
                            <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="gen">生成并复制</button>
                        </div>
                    </div>
                </div>
                <table id="LAY-qrcode-manage" lay-filter="LAY-qrcode-manage"></table>
            </div>
        </div>
    </div>

    <script src="/layuiadmin/layui/layui.js"></script>
    <script>
        layui.config({
            base: '/layuiadmin/'
            , version: "{:config('other.ui_version')}"
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'private_chat_stat', 'table', 'admin', 'laydate'], function () {
            var $ = layui.$
                , form = layui.form,
                admin = layui.admin;
            form.on('submit(gen)', function (obj) {
                //提交
                layer.load();
                admin.req({
                    url: '/admin/privatechat/gen_qrcode'
                    , data: obj.field
                    , success: function (res) {
                        layer.closeAll("loading");
                        console.log(res)
                        if (res.code == 0) {
                            $("#gen").val(res.data);
                            try {
                                navigator.clipboard.writeText(res.data);
                                parent.layer.msg("复制成功", { icon: 1 });
                                console.log('Content copied to clipboard');
                            } catch (err) {
                                console.error('Failed to copy: ', err);
                            }
                        }
                    }
                    , complete: function (res) {
                        layer.closeAll("loading");
                    }
                });
                return false;
            });
        });
    </script>


</body>

</html>